package com.test.web;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

/**
 * @author heyanjing
 * date:2020-06-09 2020/6/9:22:46
 */
@Slf4j
@MapperScan(basePackages = {"com.test.web.dao"})
@SpringBootApplication
@AllArgsConstructor
public class WebRun {

    private DataSource dataSource;

    public static void main(String[] args) {
        SpringApplication.run(WebRun.class, args);
    }

    @PostConstruct
    public void init() {
        String json = JSONUtil.toJsonStr(dataSource);
        JSONObject jsonObject = JSONUtil.parseObj(json);
        JSONObject dataSourceStat = jsonObject.getJSONObject("dataSourceStat");
        String username = jsonObject.getStr("username");
        String password = jsonObject.getStr("password");
        String url = dataSourceStat.getStr("url");
        log.info("{}  {}  {}", username, password, url);
    }

}
